package com.linchong.xshop.util;

import com.google.code.kaptcha.Constants;

import javax.servlet.http.HttpServletRequest;

/**
 * @author linchong
 * @desc 验证码工具类
 * @email littlexbear@163.com
 * @create 2018-07-16 8:14
 * @CopyRight(C) https://blog.csdn.net/littlexbear
 **/
public class CodeUtil {

    public static boolean checkVerifyCode(HttpServletRequest request){
        String verifyCodeExpected =(String) request.getSession().getAttribute(
        Constants.KAPTCHA_SESSION_KEY);

        String verifyCodeActual=HttpServletRequestUtil.getString(request,"verifyCodeActual");
        if(verifyCodeActual==null||!verifyCodeActual.equals(verifyCodeExpected)){
            return false;
        }
        return true;
    }
}
